
import 'package:floor/floor.dart';

@entity
class Message {
    @primaryKey
    final String id;
    final String content;
    final bool isUser;
    final DateTime timestamp;

    Message({
      required this.id,
      required this.content,
      required this.isUser,
      required this.timestamp
    });

    Map<String, dynamic> toJson() => {
        'id': id,
        'content': content,
        'isUser': isUser,
        'timestamp': timestamp.toIso8601String()
    };
    factory Message.fromJson(Map<String, dynamic> json) => Message(
        id: json['id'],
        content: json['content'],
        isUser: json['isUser'],
        timestamp: DateTime.parse(json['timestamp'])
    );
}